package ai.exemples;

import static org.junit.Assert.*;

import org.encog.ml.data.MLDataPair;
import org.junit.Test;

public class TestMLDataPairFactory {

	@Test
	public void test() {
		MLDataPairFactory factory = new MLDataPairFactory("./Ressources/train-images", "./Ressources/train-labels");
		MLDataPair pair = factory.getPair();
		
		assertTrue(pair.getInput().size() == 784);
		assertTrue(pair.getInput().getData(239) == 182);
		
		assertTrue(pair.getIdealArray().length == 10);
		assertTrue(pair.getIdealArray()[0] == 0);
		assertTrue(pair.getIdealArray()[1] == 0);
		assertTrue(pair.getIdealArray()[2] == 0);
		assertTrue(pair.getIdealArray()[3] == 0);
		assertTrue(pair.getIdealArray()[4] == 0);
		assertTrue(pair.getIdealArray()[5] == 1);
		assertTrue(pair.getIdealArray()[6] == 0);
		assertTrue(pair.getIdealArray()[7] == 0);
		assertTrue(pair.getIdealArray()[8] == 0);
		assertTrue(pair.getIdealArray()[9] == 0);
		
		pair = factory.getPair();
		assertTrue(pair.getInput().size() == 784);
		assertTrue(pair.getIdealArray().length == 10);
		assertTrue(pair.getIdealArray()[0] == 1);
		assertTrue(pair.getIdealArray()[1] == 0);
		assertTrue(pair.getIdealArray()[2] == 0);
		assertTrue(pair.getIdealArray()[3] == 0);
		assertTrue(pair.getIdealArray()[4] == 0);
		assertTrue(pair.getIdealArray()[5] == 0);
		assertTrue(pair.getIdealArray()[6] == 0);
		assertTrue(pair.getIdealArray()[7] == 0);
		assertTrue(pair.getIdealArray()[8] == 0);
		assertTrue(pair.getIdealArray()[9] == 0);
	}

}
